<?php

namespace app\comm\lib;

class DBCont{

    const WAIT = 0;
    const SUCCESS = 1;
    const CANCEL = 2;
    const THREE = 3;

    const PERSON = 1;
    const TEAM = 2;
    // 一般
    const ROLE_GENERAL = 0;
    // 队长
    const ROLE_CAP = 1;
    // 发布状态
    static private $_publish_status = array(
        self::WAIT => '未发布',
        self::SUCCESS => '已发布',
        self::CANCEL => '已下架',
    );
    // 收费渠道
    const FREE = 0;
    const WECHAT = 1;
    const CHARGE = 1;
    const ALIPAY = 2;
    const OFFLINE = 3;
    static private $_pay_way = [
        self::FREE => '无需交费',
        self::WECHAT => '线上支付',
        self::ALIPAY => '线上支付',
        self::OFFLINE => '线下支付',
    ];
    static private $_pay_status = [
        self::WAIT => '未支付',
        self::SUCCESS => '已支付',
        self::CANCEL => '已取消支付',
    ];
    static private $_type = [
        self::PERSON => '个人',
        self::TEAM => '团队',
    ];
    // 审核
    static private $_audit_status = [
        self::WAIT => '待审核',
        self::SUCCESS => '已通过',
        self::CANCEL => '已退回',
    ];
    static private $_match_status = [
        self::WAIT => '未开始',
        self::SUCCESS => '进行中',
        self::CANCEL => '已结束',
    ];
    static private $_fees_type = [
        self::FREE => '免费',
        self::CHARGE => '收费',
    ];
    static private $_order_status = [
        self::WAIT => '未发货',
        self::SUCCESS => '已发货',
        self::CANCEL => '已取消',
    ];
    static private $_goods_status = [
        self::SUCCESS => '正常',
        self::WAIT => '禁用'
    ];
    // 状态
    static private $_status = array(
        self::SUCCESS => '正常',
        self::WAIT => '禁用'
    );
    
    static function __callStatic($name, $arguments)
    {
        $static_name = '_';
        if(preg_match("/get(\w+)List/", $name, $matches)){
            $static_name .= parse_name($matches[1]);
            return self::getFieldList($static_name);
        } elseif (preg_match("/get(\w+)/", $name, $matches)){
            $static_name .= parse_name($matches[1]);
            return self::getFieldValue($static_name, $arguments[0]);
        }
        return null;
    }
    private static function getFieldValue($name, $arg){
        return self::${$name}[$arg];
    }
    private static function getFieldList($name){
        return self::$$name;
    }
    
}

